<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 702
</span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#if __GLASGOW_HASKELL__ &gt;= 706
</span><span class="hs-pragma">{-# LANGUAGE PolyKinds #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#if __GLASGOW_HASKELL__ &gt;= 710
</span><span class="hs-pragma">{-# LANGUAGE AutoDeriveTypeable #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Module      :  Control.Monad.Trans.Cont</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- License     :  BSD-style (see the file LICENSE)</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Maintainer  :  R.Paterson@city.ac.uk</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- Continuation monads.</span><span>
</span><span id="line-22"></span><span class="hs-comment">--</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- Delimited continuation operators are taken from Kenichi Asai and Oleg</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- Kiselyov's tutorial at CW 2011, \&quot;Introduction to programming with</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- shift and reset\&quot; (&lt;http://okmij.org/ftp/continuations/#tutorial&gt;).</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Monad.Trans.Cont</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-30"></span><span>    </span><span class="annot"><span class="hs-comment">-- * The Cont monad</span></span><span>
</span><span id="line-31"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier">Cont</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#cont"><span class="hs-identifier">cont</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#runCont"><span class="hs-identifier">runCont</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#evalCont"><span class="hs-identifier">evalCont</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#mapCont"><span class="hs-identifier">mapCont</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#withCont"><span class="hs-identifier">withCont</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Delimited continuations</span></span><span>
</span><span id="line-38"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#reset"><span class="hs-identifier">reset</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#shift"><span class="hs-identifier">shift</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>    </span><span class="annot"><span class="hs-comment">-- * The ContT monad transformer</span></span><span>
</span><span id="line-40"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier">ContT</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-identifier">evalContT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#mapContT"><span class="hs-identifier">mapContT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#withContT"><span class="hs-identifier">withContT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#callCC"><span class="hs-identifier">callCC</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Delimited continuations</span></span><span>
</span><span id="line-46"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#resetT"><span class="hs-identifier">resetT</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#shiftT"><span class="hs-identifier">shiftT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Lifting other operations</span></span><span>
</span><span id="line-48"></span><span>    </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#liftLocal"><span class="hs-identifier">liftLocal</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-49"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#"><span class="hs-identifier">Control.Monad.IO.Class</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Class.html"><span class="hs-identifier">Control.Monad.Trans.Class</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#"><span class="hs-identifier">Data.Functor.Identity</span></a></span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Applicative.html#"><span class="hs-identifier">Control.Applicative</span></a></span><span class="hs-cpp">
#if MIN_VERSION_base(4,9,0)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#"><span class="hs-identifier">Control.Monad.Fail</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Fail</span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-60"></span><span class="hs-comment">{- |
Continuation monad.
@Cont r a@ is a CPS (&quot;continuation-passing style&quot;) computation that produces an
intermediate result of type @a@ within a CPS computation whose final result type
is @r@.

The @return@ function simply creates a continuation which passes the value on.

The @&gt;&gt;=@ operator adds the bound function into the continuation chain.
-}</span><span>
</span><span id="line-70"></span><span class="hs-keyword">type</span><span> </span><span id="Cont"><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-var">Cont</span></a></span></span><span> </span><span id="local-6989586621679073240"><span class="annot"><a href="#local-6989586621679073240"><span class="hs-identifier hs-type">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073240"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span class="hs-comment">-- | Construct a continuation-passing computation from a function.</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- (The inverse of 'runCont')</span><span>
</span><span id="line-74"></span><span id="local-6989586621679073424"><span id="local-6989586621679073425"><span class="annot"><a href="Control.Monad.Trans.Cont.html#cont"><span class="hs-identifier hs-type">cont</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073425"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073424"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073424"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073424"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073425"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-75"></span><span id="cont"><span class="annot"><span class="annottext">cont :: forall a r. ((a -&gt; r) -&gt; r) -&gt; Cont r a
</span><a href="Control.Monad.Trans.Cont.html#cont"><span class="hs-identifier hs-var hs-var">cont</span></a></span></span><span> </span><span id="local-6989586621679073239"><span class="annot"><span class="annottext">(a -&gt; r) -&gt; r
</span><a href="#local-6989586621679073239"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; Identity r) -&gt; Identity r) -&gt; ContT r Identity a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073237"><span class="annot"><span class="annottext">a -&gt; Identity r
</span><a href="#local-6989586621679073237"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">r -&gt; Identity r
forall a. a -&gt; Identity a
</span><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-var">Identity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; r) -&gt; r
</span><a href="#local-6989586621679073239"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Identity r -&gt; r
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span> </span><span class="annot"><span class="annottext">(Identity r -&gt; r) -&gt; (a -&gt; Identity r) -&gt; a -&gt; r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; Identity r
</span><a href="#local-6989586621679073237"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-76"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#cont"><span class="hs-pragma hs-type">cont</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-comment">-- | The result of running a CPS computation with a given final continuation.</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- (The inverse of 'cont')</span><span>
</span><span id="line-80"></span><span id="local-6989586621679073409"><span id="local-6989586621679073410"><span class="annot"><a href="Control.Monad.Trans.Cont.html#runCont"><span class="hs-identifier hs-type">runCont</span></a></span><span>
</span><span id="line-81"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073410"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073409"><span class="hs-identifier hs-type">a</span></a></span><span>         </span><span class="hs-comment">-- ^ continuation computation (@Cont@).</span><span>
</span><span id="line-82"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073409"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073410"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span>         </span><span class="hs-comment">-- ^ the final continuation, which produces</span><span>
</span><span id="line-83"></span><span>                        </span><span class="hs-comment">-- the final result (often 'id').</span><span>
</span><span id="line-84"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073410"><span class="hs-identifier hs-type">r</span></a></span></span></span><span>
</span><span id="line-85"></span><span id="runCont"><span class="annot"><span class="annottext">runCont :: forall r a. Cont r a -&gt; (a -&gt; r) -&gt; r
</span><a href="Control.Monad.Trans.Cont.html#runCont"><span class="hs-identifier hs-var hs-var">runCont</span></a></span></span><span> </span><span id="local-6989586621679073233"><span class="annot"><span class="annottext">Cont r a
</span><a href="#local-6989586621679073233"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679073232"><span class="annot"><span class="annottext">a -&gt; r
</span><a href="#local-6989586621679073232"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Identity r -&gt; r
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cont r a -&gt; (a -&gt; Identity r) -&gt; Identity r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">Cont r a
</span><a href="#local-6989586621679073233"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">r -&gt; Identity r
forall a. a -&gt; Identity a
</span><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-var">Identity</span></a></span><span> </span><span class="annot"><span class="annottext">(r -&gt; Identity r) -&gt; (a -&gt; r) -&gt; a -&gt; Identity r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; r
</span><a href="#local-6989586621679073232"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#runCont"><span class="hs-pragma hs-type">runCont</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">-- | The result of running a CPS computation with the identity as the</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- final continuation.</span><span>
</span><span id="line-90"></span><span class="hs-comment">--</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- * @'evalCont' ('return' x) = x@</span><span>
</span><span id="line-92"></span><span id="local-6989586621679073406"><span class="annot"><a href="Control.Monad.Trans.Cont.html#evalCont"><span class="hs-identifier hs-type">evalCont</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073406"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073406"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073406"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-93"></span><span id="evalCont"><span class="annot"><span class="annottext">evalCont :: forall r. Cont r r -&gt; r
</span><a href="Control.Monad.Trans.Cont.html#evalCont"><span class="hs-identifier hs-var hs-var">evalCont</span></a></span></span><span> </span><span id="local-6989586621679073228"><span class="annot"><span class="annottext">Cont r r
</span><a href="#local-6989586621679073228"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Identity r -&gt; r
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cont r r -&gt; Identity r
forall (m :: * -&gt; *) r. Monad m =&gt; ContT r m r -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-identifier hs-var">evalContT</span></a></span><span> </span><span class="annot"><span class="annottext">Cont r r
</span><a href="#local-6989586621679073228"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#evalCont"><span class="hs-pragma hs-type">evalCont</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="hs-comment">-- | Apply a function to transform the result of a continuation-passing</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- computation.</span><span>
</span><span id="line-98"></span><span class="hs-comment">--</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- * @'runCont' ('mapCont' f m) = f . 'runCont' m@</span><span>
</span><span id="line-100"></span><span id="local-6989586621679073401"><span id="local-6989586621679073402"><span class="annot"><a href="Control.Monad.Trans.Cont.html#mapCont"><span class="hs-identifier hs-type">mapCont</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073402"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073402"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073402"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073401"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073402"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073401"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-101"></span><span id="mapCont"><span class="annot"><span class="annottext">mapCont :: forall r a. (r -&gt; r) -&gt; Cont r a -&gt; Cont r a
</span><a href="Control.Monad.Trans.Cont.html#mapCont"><span class="hs-identifier hs-var hs-var">mapCont</span></a></span></span><span> </span><span id="local-6989586621679073227"><span class="annot"><span class="annottext">r -&gt; r
</span><a href="#local-6989586621679073227"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Identity r -&gt; Identity r)
-&gt; ContT r Identity a -&gt; ContT r Identity a
forall {k} (m :: k -&gt; *) (r :: k) a.
(m r -&gt; m r) -&gt; ContT r m a -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#mapContT"><span class="hs-identifier hs-var">mapContT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">r -&gt; Identity r
forall a. a -&gt; Identity a
</span><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-var">Identity</span></a></span><span> </span><span class="annot"><span class="annottext">(r -&gt; Identity r) -&gt; (Identity r -&gt; r) -&gt; Identity r -&gt; Identity r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">r -&gt; r
</span><a href="#local-6989586621679073227"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(r -&gt; r) -&gt; (Identity r -&gt; r) -&gt; Identity r -&gt; r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Identity r -&gt; r
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#mapCont"><span class="hs-pragma hs-type">mapCont</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-comment">-- | Apply a function to transform the continuation passed to a CPS</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- computation.</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- * @'runCont' ('withCont' f m) = 'runCont' m . f@</span><span>
</span><span id="line-108"></span><span id="local-6989586621679073392"><span id="local-6989586621679073393"><span id="local-6989586621679073394"><span class="annot"><a href="Control.Monad.Trans.Cont.html#withCont"><span class="hs-identifier hs-type">withCont</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073394"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073393"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073392"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073393"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073393"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073392"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073393"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073394"><span class="hs-identifier hs-type">b</span></a></span></span></span></span><span>
</span><span id="line-109"></span><span id="withCont"><span class="annot"><span class="annottext">withCont :: forall b r a. ((b -&gt; r) -&gt; a -&gt; r) -&gt; Cont r a -&gt; Cont r b
</span><a href="Control.Monad.Trans.Cont.html#withCont"><span class="hs-identifier hs-var hs-var">withCont</span></a></span></span><span> </span><span id="local-6989586621679073226"><span class="annot"><span class="annottext">(b -&gt; r) -&gt; a -&gt; r
</span><a href="#local-6989586621679073226"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((b -&gt; Identity r) -&gt; a -&gt; Identity r)
-&gt; ContT r Identity a -&gt; ContT r Identity b
forall {k} b (m :: k -&gt; *) (r :: k) a.
((b -&gt; m r) -&gt; a -&gt; m r) -&gt; ContT r m a -&gt; ContT r m b
</span><a href="Control.Monad.Trans.Cont.html#withContT"><span class="hs-identifier hs-var">withContT</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">r -&gt; Identity r
forall a. a -&gt; Identity a
</span><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-var">Identity</span></a></span><span> </span><span class="annot"><span class="annottext">(r -&gt; Identity r) -&gt; (a -&gt; r) -&gt; a -&gt; Identity r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((a -&gt; r) -&gt; a -&gt; Identity r)
-&gt; ((b -&gt; Identity r) -&gt; a -&gt; r)
-&gt; (b -&gt; Identity r)
-&gt; a
-&gt; Identity r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; r) -&gt; a -&gt; r
</span><a href="#local-6989586621679073226"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">((b -&gt; r) -&gt; a -&gt; r)
-&gt; ((b -&gt; Identity r) -&gt; b -&gt; r) -&gt; (b -&gt; Identity r) -&gt; a -&gt; r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Identity r -&gt; r
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span> </span><span class="annot"><span class="annottext">(Identity r -&gt; r) -&gt; (b -&gt; Identity r) -&gt; b -&gt; r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#withCont"><span class="hs-pragma hs-type">withCont</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- | @'reset' m@ delimits the continuation of any 'shift' inside @m@.</span><span>
</span><span id="line-113"></span><span class="hs-comment">--</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- * @'reset' ('return' m) = 'return' m@</span><span>
</span><span id="line-115"></span><span class="hs-comment">--</span><span>
</span><span id="line-116"></span><span id="local-6989586621679073382"><span id="local-6989586621679073383"><span class="annot"><a href="Control.Monad.Trans.Cont.html#reset"><span class="hs-identifier hs-type">reset</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073383"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073383"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073382"><span class="hs-identifier hs-type">r'</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073383"><span class="hs-identifier hs-type">r</span></a></span></span></span><span>
</span><span id="line-117"></span><span id="reset"><span class="annot"><span class="annottext">reset :: forall r r'. Cont r r -&gt; Cont r' r
</span><a href="Control.Monad.Trans.Cont.html#reset"><span class="hs-identifier hs-var hs-var">reset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ContT r Identity r -&gt; ContT r' Identity r
forall (m :: * -&gt; *) r r'. Monad m =&gt; ContT r m r -&gt; ContT r' m r
</span><a href="Control.Monad.Trans.Cont.html#resetT"><span class="hs-identifier hs-var">resetT</span></a></span><span>
</span><span id="line-118"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#reset"><span class="hs-pragma hs-type">reset</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-comment">-- | @'shift' f@ captures the continuation up to the nearest enclosing</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- 'reset' and passes it to @f@:</span><span>
</span><span id="line-122"></span><span class="hs-comment">--</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- * @'reset' ('shift' f &gt;&gt;= k) = 'reset' (f ('evalCont' . k))@</span><span>
</span><span id="line-124"></span><span class="hs-comment">--</span><span>
</span><span id="line-125"></span><span id="local-6989586621679073375"><span id="local-6989586621679073376"><span class="annot"><a href="Control.Monad.Trans.Cont.html#shift"><span class="hs-identifier hs-type">shift</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073376"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073375"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073375"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073375"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#Cont"><span class="hs-identifier hs-type">Cont</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073375"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073376"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-126"></span><span id="shift"><span class="annot"><span class="annottext">shift :: forall a r. ((a -&gt; r) -&gt; Cont r r) -&gt; Cont r a
</span><a href="Control.Monad.Trans.Cont.html#shift"><span class="hs-identifier hs-var hs-var">shift</span></a></span></span><span> </span><span id="local-6989586621679073223"><span class="annot"><span class="annottext">(a -&gt; r) -&gt; Cont r r
</span><a href="#local-6989586621679073223"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; Identity r) -&gt; Cont r r) -&gt; ContT r Identity a
forall (m :: * -&gt; *) a r.
Monad m =&gt;
((a -&gt; m r) -&gt; ContT r m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#shiftT"><span class="hs-identifier hs-var">shiftT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; r) -&gt; Cont r r
</span><a href="#local-6989586621679073223"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">((a -&gt; r) -&gt; Cont r r)
-&gt; ((a -&gt; Identity r) -&gt; a -&gt; r) -&gt; (a -&gt; Identity r) -&gt; Cont r r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Identity r -&gt; r
forall a. Identity a -&gt; a
</span><a href="../../base/src/Data.Functor.Identity.html#runIdentity"><span class="hs-identifier hs-var hs-var">runIdentity</span></a></span><span> </span><span class="annot"><span class="annottext">(Identity r -&gt; r) -&gt; (a -&gt; Identity r) -&gt; a -&gt; r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#shift"><span class="hs-pragma hs-type">shift</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="hs-comment">-- | The continuation monad transformer.</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- Can be used to add continuation handling to any type constructor:</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- the 'Monad' instance and most of the operations do not require @m@</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- to be a monad.</span><span>
</span><span id="line-133"></span><span class="hs-comment">--</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- 'ContT' is not a functor on the category of monads, and many operations</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- cannot be lifted through it.</span><span>
</span><span id="line-136"></span><span class="hs-keyword">newtype</span><span> </span><span id="ContT"><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span></span><span> </span><span id="local-6989586621679073416"><span class="annot"><a href="#local-6989586621679073416"><span class="hs-identifier hs-type">r</span></a></span></span><span> </span><span id="local-6989586621679073417"><span class="annot"><a href="#local-6989586621679073417"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span id="local-6989586621679073418"><span class="annot"><a href="#local-6989586621679073418"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ContT"><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="runContT"><span class="annot"><span class="annottext">forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073418"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073417"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073416"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073417"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073416"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span class="hs-comment">-- | The result of running a CPS computation with 'return' as the</span><span>
</span><span id="line-139"></span><span class="hs-comment">-- final continuation.</span><span>
</span><span id="line-140"></span><span class="hs-comment">--</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- * @'evalContT' ('lift' m) = m@</span><span>
</span><span id="line-142"></span><span id="local-6989586621679073403"><span id="local-6989586621679073404"><span class="annot"><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-identifier hs-type">evalContT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073404"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073403"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073404"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073403"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073404"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073403"><span class="hs-identifier hs-type">r</span></a></span></span></span><span>
</span><span id="line-143"></span><span id="evalContT"><span class="annot"><span class="annottext">evalContT :: forall (m :: * -&gt; *) r. Monad m =&gt; ContT r m r -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-identifier hs-var hs-var">evalContT</span></a></span></span><span> </span><span id="local-6989586621679073220"><span class="annot"><span class="annottext">ContT r m r
</span><a href="#local-6989586621679073220"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ContT r m r -&gt; (r -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m r
</span><a href="#local-6989586621679073220"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">r -&gt; m r
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>
</span><span id="line-144"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-pragma hs-type">evalContT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span class="hs-comment">-- | Apply a function to transform the result of a continuation-passing</span><span>
</span><span id="line-147"></span><span class="hs-comment">-- computation.  This has a more restricted type than the @map@ operations</span><span>
</span><span id="line-148"></span><span class="hs-comment">-- for other monad transformers, because 'ContT' does not define a functor</span><span>
</span><span id="line-149"></span><span class="hs-comment">-- in the category of monads.</span><span>
</span><span id="line-150"></span><span class="hs-comment">--</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- * @'runContT' ('mapContT' f m) = f . 'runContT' m@</span><span>
</span><span id="line-152"></span><span id="local-6989586621679073395"><span id="local-6989586621679073396"><span id="local-6989586621679073397"><span class="annot"><a href="Control.Monad.Trans.Cont.html#mapContT"><span class="hs-identifier hs-type">mapContT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073397"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073396"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073397"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073396"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073396"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073397"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073395"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073396"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073397"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073395"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-153"></span><span id="mapContT"><span class="annot"><span class="annottext">mapContT :: forall {k} (m :: k -&gt; *) (r :: k) a.
(m r -&gt; m r) -&gt; ContT r m a -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#mapContT"><span class="hs-identifier hs-var hs-var">mapContT</span></a></span></span><span> </span><span id="local-6989586621679073219"><span class="annot"><span class="annottext">m r -&gt; m r
</span><a href="#local-6989586621679073219"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679073218"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073218"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((a -&gt; m r) -&gt; m r) -&gt; ContT r m a)
-&gt; ((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">m r -&gt; m r
</span><a href="#local-6989586621679073219"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(m r -&gt; m r) -&gt; ((a -&gt; m r) -&gt; m r) -&gt; (a -&gt; m r) -&gt; m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073218"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-154"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#mapContT"><span class="hs-pragma hs-type">mapContT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span class="hs-comment">-- | Apply a function to transform the continuation passed to a CPS</span><span>
</span><span id="line-157"></span><span class="hs-comment">-- computation.</span><span>
</span><span id="line-158"></span><span class="hs-comment">--</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- * @'runContT' ('withContT' f m) = 'runContT' m . f@</span><span>
</span><span id="line-160"></span><span id="local-6989586621679073384"><span id="local-6989586621679073385"><span id="local-6989586621679073386"><span id="local-6989586621679073387"><span class="annot"><a href="Control.Monad.Trans.Cont.html#withContT"><span class="hs-identifier hs-type">withContT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073387"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073386"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073385"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073384"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073386"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073385"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073385"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073386"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073384"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073385"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073386"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073387"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span><span>
</span><span id="line-161"></span><span id="withContT"><span class="annot"><span class="annottext">withContT :: forall {k} b (m :: k -&gt; *) (r :: k) a.
((b -&gt; m r) -&gt; a -&gt; m r) -&gt; ContT r m a -&gt; ContT r m b
</span><a href="Control.Monad.Trans.Cont.html#withContT"><span class="hs-identifier hs-var hs-var">withContT</span></a></span></span><span> </span><span id="local-6989586621679073217"><span class="annot"><span class="annottext">(b -&gt; m r) -&gt; a -&gt; m r
</span><a href="#local-6989586621679073217"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679073216"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073216"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((b -&gt; m r) -&gt; m r) -&gt; ContT r m b)
-&gt; ((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073216"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r)
-&gt; ((b -&gt; m r) -&gt; a -&gt; m r) -&gt; (b -&gt; m r) -&gt; m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; m r) -&gt; a -&gt; m r
</span><a href="#local-6989586621679073217"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-162"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#withContT"><span class="hs-pragma hs-type">withContT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span id="local-6989586621679073342"><span id="local-6989586621679073343"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679073213"><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073343"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073342"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-165"></span><span>    </span><span id="local-6989586621679073211"><span class="annot"><span class="annottext">fmap :: forall a b. (a -&gt; b) -&gt; ContT r m a -&gt; ContT r m b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var hs-var hs-var hs-var">fmap</span></a></span></span><span> </span><span id="local-6989586621679073210"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679073210"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679073209"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073209"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((b -&gt; m r) -&gt; m r) -&gt; ContT r m b)
-&gt; ((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073208"><span class="annot"><span class="annottext">b -&gt; m r
</span><a href="#local-6989586621679073208"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073209"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b -&gt; m r
</span><a href="#local-6989586621679073208"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; m r) -&gt; (a -&gt; b) -&gt; a -&gt; m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679073210"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-pragma hs-type">fmap</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span id="local-6989586621679073326"><span id="local-6989586621679073327"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679073199"><span id="local-6989586621679073202"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073327"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073326"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-169"></span><span>    </span><span id="local-6989586621679073197"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; ContT r m a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621679073196"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679073196"><span class="hs-identifier hs-var">x</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; m r) -&gt; a -&gt; m r
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679073196"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#pure"><span class="hs-pragma hs-type">pure</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-171"></span><span>    </span><span id="local-6989586621679073195"><span class="annot"><span class="annottext">ContT r m (a -&gt; b)
</span><a href="#local-6989586621679073195"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679073194"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. ContT r m (a -&gt; b) -&gt; ContT r m a -&gt; ContT r m b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;*&gt;</span></a></span></span><span> </span><span id="local-6989586621679073193"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073193"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((b -&gt; m r) -&gt; m r) -&gt; ContT r m b)
-&gt; ((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073192"><span class="annot"><span class="annottext">b -&gt; m r
</span><a href="#local-6989586621679073192"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m (a -&gt; b) -&gt; ((a -&gt; b) -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m (a -&gt; b)
</span><a href="#local-6989586621679073195"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(((a -&gt; b) -&gt; m r) -&gt; m r) -&gt; ((a -&gt; b) -&gt; m r) -&gt; m r
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073191"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679073191"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073193"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b -&gt; m r
</span><a href="#local-6989586621679073192"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; m r) -&gt; (a -&gt; b) -&gt; a -&gt; m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679073191"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-172"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&lt;*&gt;</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-173"></span><span>    </span><span id="local-6989586621679073189"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073189"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679073188"><span class="annot"><span class="annottext">*&gt; :: forall a b. ContT r m a -&gt; ContT r m b -&gt; ContT r m b
</span><a href="../../base/src/GHC.Base.html#%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">*&gt;</span></a></span></span><span> </span><span id="local-6989586621679073187"><span class="annot"><span class="annottext">ContT r m b
</span><a href="#local-6989586621679073187"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073189"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; ContT r m b) -&gt; ContT r m b
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m b
</span><a href="#local-6989586621679073187"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-174"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">*&gt;</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span id="local-6989586621679073320"><span id="local-6989586621679073321"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679073180"><span id="local-6989586621679073182"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073321"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073320"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">
#if !(MIN_VERSION_base(4,8,0))
</span><span>    </span><span class="hs-identifier">return</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ContT</span><span> </span><span class="hs-special">(</span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">x</span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">return</span><span> </span><span class="hs-pragma">#-}</span><span class="hs-cpp">
#endif
</span><span>    </span><span id="local-6989586621679073178"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073178"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679073177"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. ContT r m a -&gt; (a -&gt; ContT r m b) -&gt; ContT r m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621679073176"><span class="annot"><span class="annottext">a -&gt; ContT r m b
</span><a href="#local-6989586621679073176"><span class="hs-identifier hs-var">k</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((b -&gt; m r) -&gt; m r) -&gt; ContT r m b)
-&gt; ((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073175"><span class="annot"><span class="annottext">b -&gt; m r
</span><a href="#local-6989586621679073175"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073178"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073174"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679073174"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m b -&gt; (b -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; ContT r m b
</span><a href="#local-6989586621679073176"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679073174"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">b -&gt; m r
</span><a href="#local-6989586621679073175"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&gt;&gt;=</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span></span></span><span class="hs-cpp">

#if MIN_VERSION_base(4,9,0)
</span><span id="local-6989586621679073306"><span id="local-6989586621679073307"><span class="hs-keyword">instance</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">Fail.MonadFail</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073307"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">Fail.MonadFail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073306"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073307"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-186"></span><span>    </span><span id="local-6989586621679073166"><span class="annot"><span class="annottext">fail :: forall a. String -&gt; ContT r m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var hs-var hs-var hs-var">fail</span></a></span></span><span> </span><span id="local-6989586621679073165"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679073165"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((a -&gt; m r) -&gt; m r) -&gt; ContT r m a)
-&gt; ((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">a -&gt; m r
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; m r
forall (m :: * -&gt; *) a. MonadFail m =&gt; String -&gt; m a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var">Fail.fail</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679073165"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-187"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-pragma hs-type">fail</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-190"></span><span id="local-6989586621679073299"><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Class.html#MonadTrans"><span class="hs-identifier hs-type">MonadTrans</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073299"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-191"></span><span>    </span><span id="local-6989586621679073159"><span class="annot"><span class="annottext">lift :: forall (m :: * -&gt; *) a. Monad m =&gt; m a -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var hs-var hs-var hs-var">lift</span></a></span></span><span> </span><span id="local-6989586621679073157"><span class="annot"><span class="annottext">m a
</span><a href="#local-6989586621679073157"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">m a
</span><a href="#local-6989586621679073157"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">m a -&gt; (a -&gt; m r) -&gt; m r
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-192"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-pragma hs-type">lift</span></a></span><span> </span><span class="hs-pragma">#-}</span></span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span id="local-6989586621679073290"><span id="local-6989586621679073291"><span class="hs-keyword">instance</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073291"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073290"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073291"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-195"></span><span>    </span><span id="local-6989586621679073145"><span class="annot"><span class="annottext">liftIO :: forall a. IO a -&gt; ContT r m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var hs-var hs-var hs-var">liftIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m a -&gt; ContT r m a
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(m a -&gt; ContT r m a) -&gt; (IO a -&gt; m a) -&gt; IO a -&gt; ContT r m a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IO a -&gt; m a
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span>
</span><span id="line-196"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-pragma hs-type">liftIO</span></a></span><span> </span><span class="hs-pragma">#-}</span></span></span><span>
</span><span id="line-197"></span><span>
</span><span id="line-198"></span><span class="hs-comment">-- | @callCC@ (call-with-current-continuation) calls its argument</span><span>
</span><span id="line-199"></span><span class="hs-comment">-- function, passing it the current continuation.  It provides</span><span>
</span><span id="line-200"></span><span class="hs-comment">-- an escape continuation mechanism for use with continuation</span><span>
</span><span id="line-201"></span><span class="hs-comment">-- monads.  Escape continuations one allow to abort the current</span><span>
</span><span id="line-202"></span><span class="hs-comment">-- computation and return a value immediately.  They achieve</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- a similar effect to 'Control.Monad.Trans.Except.throwE'</span><span>
</span><span id="line-204"></span><span class="hs-comment">-- and 'Control.Monad.Trans.Except.catchE' within an</span><span>
</span><span id="line-205"></span><span class="hs-comment">-- 'Control.Monad.Trans.Except.ExceptT' monad.  The advantage of this</span><span>
</span><span id="line-206"></span><span class="hs-comment">-- function over calling 'return' is that it makes the continuation</span><span>
</span><span id="line-207"></span><span class="hs-comment">-- explicit, allowing more flexibility and better control.</span><span>
</span><span id="line-208"></span><span class="hs-comment">--</span><span>
</span><span id="line-209"></span><span class="hs-comment">-- The standard idiom used with @callCC@ is to provide a lambda-expression</span><span>
</span><span id="line-210"></span><span class="hs-comment">-- to name the continuation. Then calling the named continuation anywhere</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- within its scope will escape from the computation, even if it is many</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- layers deep within nested computations.</span><span>
</span><span id="line-213"></span><span id="local-6989586621679073284"><span id="local-6989586621679073285"><span id="local-6989586621679073286"><span id="local-6989586621679073287"><span class="annot"><a href="Control.Monad.Trans.Cont.html#callCC"><span class="hs-identifier hs-type">callCC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073287"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073286"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073285"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073284"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073286"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073285"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073287"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073286"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073285"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073287"><span class="hs-identifier hs-type">a</span></a></span></span></span></span></span><span>
</span><span id="line-214"></span><span id="callCC"><span class="annot"><span class="annottext">callCC :: forall {k} a (r :: k) (m :: k -&gt; *) b.
((a -&gt; ContT r m b) -&gt; ContT r m a) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#callCC"><span class="hs-identifier hs-var hs-var">callCC</span></a></span></span><span> </span><span id="local-6989586621679073143"><span class="annot"><span class="annottext">(a -&gt; ContT r m b) -&gt; ContT r m a
</span><a href="#local-6989586621679073143"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((a -&gt; m r) -&gt; m r) -&gt; ContT r m a)
-&gt; ((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073142"><span class="annot"><span class="annottext">a -&gt; m r
</span><a href="#local-6989586621679073142"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; ContT r m b) -&gt; ContT r m a
</span><a href="#local-6989586621679073143"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073141"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679073141"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((b -&gt; m r) -&gt; m r) -&gt; ContT r m b)
-&gt; ((b -&gt; m r) -&gt; m r) -&gt; ContT r m b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">b -&gt; m r
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; m r
</span><a href="#local-6989586621679073142"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679073141"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a -&gt; m r
</span><a href="#local-6989586621679073142"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-215"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#callCC"><span class="hs-pragma hs-type">callCC</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-216"></span><span>
</span><span id="line-217"></span><span class="hs-comment">-- | @'resetT' m@ delimits the continuation of any 'shiftT' inside @m@.</span><span>
</span><span id="line-218"></span><span class="hs-comment">--</span><span>
</span><span id="line-219"></span><span class="hs-comment">-- * @'resetT' ('lift' m) = 'lift' m@</span><span>
</span><span id="line-220"></span><span class="hs-comment">--</span><span>
</span><span id="line-221"></span><span id="local-6989586621679073377"><span id="local-6989586621679073378"><span id="local-6989586621679073379"><span class="annot"><a href="Control.Monad.Trans.Cont.html#resetT"><span class="hs-identifier hs-type">resetT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073379"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073378"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073379"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073378"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073377"><span class="hs-identifier hs-type">r'</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073379"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073378"><span class="hs-identifier hs-type">r</span></a></span></span></span></span><span>
</span><span id="line-222"></span><span id="resetT"><span class="annot"><span class="annottext">resetT :: forall (m :: * -&gt; *) r r'. Monad m =&gt; ContT r m r -&gt; ContT r' m r
</span><a href="Control.Monad.Trans.Cont.html#resetT"><span class="hs-identifier hs-var hs-var">resetT</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m r -&gt; ContT r' m r
forall (t :: (* -&gt; *) -&gt; * -&gt; *) (m :: * -&gt; *) a.
(MonadTrans t, Monad m) =&gt;
m a -&gt; t m a
</span><a href="Control.Monad.Trans.Class.html#lift"><span class="hs-identifier hs-var">lift</span></a></span><span> </span><span class="annot"><span class="annottext">(m r -&gt; ContT r' m r)
-&gt; (ContT r m r -&gt; m r) -&gt; ContT r m r -&gt; ContT r' m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m r -&gt; m r
forall (m :: * -&gt; *) r. Monad m =&gt; ContT r m r -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-identifier hs-var">evalContT</span></a></span><span>
</span><span id="line-223"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#resetT"><span class="hs-pragma hs-type">resetT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-224"></span><span>
</span><span id="line-225"></span><span class="hs-comment">-- | @'shiftT' f@ captures the continuation up to the nearest enclosing</span><span>
</span><span id="line-226"></span><span class="hs-comment">-- 'resetT' and passes it to @f@:</span><span>
</span><span id="line-227"></span><span class="hs-comment">--</span><span>
</span><span id="line-228"></span><span class="hs-comment">-- * @'resetT' ('shiftT' f &gt;&gt;= k) = 'resetT' (f ('evalContT' . k))@</span><span>
</span><span id="line-229"></span><span class="hs-comment">--</span><span>
</span><span id="line-230"></span><span id="local-6989586621679073370"><span id="local-6989586621679073371"><span id="local-6989586621679073372"><span class="annot"><a href="Control.Monad.Trans.Cont.html#shiftT"><span class="hs-identifier hs-type">shiftT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073372"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073371"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073372"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073370"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073370"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073372"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073370"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073370"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073372"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073371"><span class="hs-identifier hs-type">a</span></a></span></span></span></span><span>
</span><span id="line-231"></span><span id="shiftT"><span class="annot"><span class="annottext">shiftT :: forall (m :: * -&gt; *) a r.
Monad m =&gt;
((a -&gt; m r) -&gt; ContT r m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#shiftT"><span class="hs-identifier hs-var hs-var">shiftT</span></a></span></span><span> </span><span id="local-6989586621679073134"><span class="annot"><span class="annottext">(a -&gt; m r) -&gt; ContT r m r
</span><a href="#local-6989586621679073134"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ContT r m r -&gt; m r
forall (m :: * -&gt; *) r. Monad m =&gt; ContT r m r -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#evalContT"><span class="hs-identifier hs-var">evalContT</span></a></span><span> </span><span class="annot"><span class="annottext">(ContT r m r -&gt; m r)
-&gt; ((a -&gt; m r) -&gt; ContT r m r) -&gt; (a -&gt; m r) -&gt; m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; m r) -&gt; ContT r m r
</span><a href="#local-6989586621679073134"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#shiftT"><span class="hs-pragma hs-type">shiftT</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span class="hs-comment">-- | @'liftLocal' ask local@ yields a @local@ function for @'ContT' r m@.</span><span>
</span><span id="line-235"></span><span id="local-6989586621679073269"><span id="local-6989586621679073270"><span id="local-6989586621679073271"><span id="local-6989586621679073272"><span class="annot"><a href="Control.Monad.Trans.Cont.html#liftLocal"><span class="hs-identifier hs-type">liftLocal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073272"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073272"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073271"><span class="hs-identifier hs-type">r'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073271"><span class="hs-identifier hs-type">r'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073271"><span class="hs-identifier hs-type">r'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073272"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073270"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073272"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073270"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-236"></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679073271"><span class="hs-identifier hs-type">r'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679073271"><span class="hs-identifier hs-type">r'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073270"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073272"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073269"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-type">ContT</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073270"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073272"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679073269"><span class="hs-identifier hs-type">a</span></a></span></span></span></span></span><span>
</span><span id="line-237"></span><span id="liftLocal"><span class="annot"><span class="annottext">liftLocal :: forall (m :: * -&gt; *) r' r a.
Monad m =&gt;
m r'
-&gt; ((r' -&gt; r') -&gt; m r -&gt; m r)
-&gt; (r' -&gt; r')
-&gt; ContT r m a
-&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#liftLocal"><span class="hs-identifier hs-var hs-var">liftLocal</span></a></span></span><span> </span><span id="local-6989586621679073131"><span class="annot"><span class="annottext">m r'
</span><a href="#local-6989586621679073131"><span class="hs-identifier hs-var">ask</span></a></span></span><span> </span><span id="local-6989586621679073130"><span class="annot"><span class="annottext">(r' -&gt; r') -&gt; m r -&gt; m r
</span><a href="#local-6989586621679073130"><span class="hs-identifier hs-var">local</span></a></span></span><span> </span><span id="local-6989586621679073129"><span class="annot"><span class="annottext">r' -&gt; r'
</span><a href="#local-6989586621679073129"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679073128"><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073128"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall {k} (r :: k) (m :: k -&gt; *) a.
((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
</span><a href="Control.Monad.Trans.Cont.html#ContT"><span class="hs-identifier hs-var">ContT</span></a></span><span> </span><span class="annot"><span class="annottext">(((a -&gt; m r) -&gt; m r) -&gt; ContT r m a)
-&gt; ((a -&gt; m r) -&gt; m r) -&gt; ContT r m a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679073127"><span class="annot"><span class="annottext">a -&gt; m r
</span><a href="#local-6989586621679073127"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-238"></span><span>    </span><span id="local-6989586621679073126"><span class="annot"><span class="annottext">r'
</span><a href="#local-6989586621679073126"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m r'
</span><a href="#local-6989586621679073131"><span class="hs-identifier hs-var">ask</span></a></span><span>
</span><span id="line-239"></span><span>    </span><span class="annot"><span class="annottext">(r' -&gt; r') -&gt; m r -&gt; m r
</span><a href="#local-6989586621679073130"><span class="hs-identifier hs-var">local</span></a></span><span> </span><span class="annot"><span class="annottext">r' -&gt; r'
</span><a href="#local-6989586621679073129"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ContT r m a -&gt; (a -&gt; m r) -&gt; m r
forall {k} (r :: k) (m :: k -&gt; *) a.
ContT r m a -&gt; (a -&gt; m r) -&gt; m r
</span><a href="Control.Monad.Trans.Cont.html#runContT"><span class="hs-identifier hs-var hs-var">runContT</span></a></span><span> </span><span class="annot"><span class="annottext">ContT r m a
</span><a href="#local-6989586621679073128"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(r' -&gt; r') -&gt; m r -&gt; m r
</span><a href="#local-6989586621679073130"><span class="hs-identifier hs-var">local</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">r' -&gt; r' -&gt; r'
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">r'
</span><a href="#local-6989586621679073126"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(m r -&gt; m r) -&gt; (a -&gt; m r) -&gt; a -&gt; m r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m r
</span><a href="#local-6989586621679073127"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Control.Monad.Trans.Cont.html#liftLocal"><span class="hs-pragma hs-type">liftLocal</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-241"></span></pre></body></html>